#!/usr/bin/python
class SalesRouting:
    vt = {}
    ad = ()
    def howMany(self, adj):
        ret = 0;
        self.ad = adj
        ret += self.walk(0);
        return ret;
    def walk(self, v):
        if v==1:
            return 1
        self.vt[v] = 1
        s = 0
        for w in range(len(self.ad[v])):
            print (v,w), self.vt, self.ad[v][w]
            if self.ad[v][w]!='0' and not w in self.vt:
                print 'entering',w
                s += self.walk(w)
        return s

example  = SalesRouting()
print example.howMany(("0011000", "0000011", "1000100", "1000100", "0011011", "0100100", "0100100"
))
